Assignemnt #64 and 62nd program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: 62nd Program
///File name: Sixt2Prog.java
///Date Finished:11/16/2015
import java.util.Scanner;
public class Sixt2Prog
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int pin = 12345;
int tries = 0;
System.out.println("WELCOME TO THE BANK.");
System.out.print("ENTER YOUR PIN: ");
int entry = keyboard.nextInt();
tries++;
while ( entry != pin && tries < 4 )
{
System.out.println("\nINCORRECT PIN. TRY AGAIN.");
System.out.print("ENTER YOUR PIN: ");
entry = keyboard.nextInt();
tries++;
}
if ( entry == pin )
System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
else if ( tries >= 4 )
System.out.println("\nYOU ARE OUT OF ATTEMPTS. YOUR MONEY IS MINE NOW.");
}
}
Picture of the output